import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-04-07
 * Time: 16:15
 */
public class DeleteEdge {
    //高通滤波
    //边缘检测
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("src2.png", Imgcodecs.IMREAD_GRAYSCALE);
        Mat mat = new Mat();
        Imgproc.Sobel(src, mat, -1, 0, 1);

        HighGui.imshow("sobel", mat);
        HighGui.waitKey();

        Imgproc.Scharr(src, mat, -1, 0, 1);

        HighGui.imshow("sch-arr", mat);
        HighGui.waitKey();

        Mat dst = new Mat();
        Imgproc.GaussianBlur(src, dst, new Size(31, 5), 80, 3);
        Imgproc.Laplacian(src, dst, 0);

        HighGui.imshow("Laplacian", dst);
        HighGui.waitKey();

        Imgproc.Canny(src, dst, 60, 200);//最小阈值和最大阈值中间范围过大时检测到的边缘比较少
        HighGui.imshow("Canny", dst);
        HighGui.waitKey();
    }
}
